
var app = getApp();


Page({

  /**
   * 页面的初始数据
   */
  data: {
    type: "jwc",
    types: {
      id: {
        name: "信息门户",
        url: "/id_bind",
        verify: "id_verify",
        password: "id_password",
        help: "密码为教务网账号密码，"
      },
      library: {
        name: "图书馆",
        url: "/library/bind",
        verify: "library_verify",
        help: "密码错误可自行上教务网进行"
      },
      jwc: {
        name: "教务处",
        url: "/bind",
        verify: "jwc_verify",
        password: "jwc_password",
        help: "说明信息："
      }
    },
    openId: '',
    userid_focus: false,
    passwd_focus: false,
    class_focus: false,
    angle: 0,
    help_status: false,
    tem_file_id: '',
    username: '',
    password: '',
    check_word: '',
    the_cookie: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.type = options.type || this.data.type;
    console.log(this.data.type)
    this.setData({
      type: this.type
    })
  },
  tapHelp: function (e) {
    if (e.target.id == 'help') {
      this.hideHelp();
    }
  },

  showHelp: function (e) {
    this.setData({
      'help_status': true
    });
  },
  hideHelp: function (e) {
    this.setData({
      'help_status': false
    });
  },
  UidInput: function (e) {
    if (e.detail.value.length >= 13) {
      wx.hideKeyboard();
    }
  },
  ClassInput: function (e) {

  },

  inputFocus: function (e) {
    if (e.target.id == 'userid') {
      this.setData({
        'userid_focus': true
      });
    } else if (e.target.id == 'passwd') {
      this.setData({
        'passwd_focus': true
      });
    }
  },
  inputBlur: function (e) {
    if (e.target.id == 'userid') {
      this.setData({
        'userid_focus': false
      });
    } else if (e.target.id == 'passwd') {
      this.setData({
        'passwd_focus': false
      });
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },


  // 登录
  login(e) {
    var form = e.detail.value
    console.log(form)
    if (form.uid == "" | form.pwd == "") {
      wx.showToast({
        icon: 'error',
        title: '请输入完整',
      })
      return
    }

    wx.showLoading({
      title: '访问教务网中...',
    })
    if (form.uid == '2020' && form.pwd == '2020') {
      wx.setStorageSync('is_bind', true);
      wx.showToast({
        icon: 'success',
        title: '成功绑定教务网',
        duration: 3000
      })
      wx.navigateBack({
        delta: 1,
      })
    }
    else{
      wx.showToast({
        icon: 'error',
        title: '账号密码错误',
        duration: 3000
      })
    }
  }
})